import Vue from 'vue'

import { Input } from 'element-ui';
import App from './App.vue'
import router from './router'
import store from './store'
import 'lib-flexible/flexible'
import axios from 'axios'
import VueAxios from 'vue-axios'
import './filters/index'

import { Swipe, SwipeItem } from 'vant';
import { List } from 'vant';
import { Tabbar, TabbarItem } from 'vant';
import { Icon } from 'vant';
import { NavBar } from 'vant';
import { Form } from 'vant';
import { Field } from 'vant';
import { Button } from 'vant';
import { ShareSheet } from 'vant';
import { Cell } from 'vant';
import { Popup } from 'vant';
import { PullRefresh } from 'vant';
import { Toast } from 'vant';
import waterfall from 'vue-waterfall2'
import infiniteScroll from 'vue-infinite-scroll'
import { Sticky } from 'vant';
import { Tab, Tabs } from 'vant';
import { DropdownMenu, DropdownItem } from 'vant';
import VueRouter from 'vue-router'
import { Search } from 'vant';
import { Dialog } from 'vant';
import { CellGroup } from 'vant';
import { Tag } from 'vant';








Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Input)
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(VueAxios, axios)
Vue.use(Toast);
Vue.use(List);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(Tabbar);
Vue.use(TabbarItem);
Vue.use(Icon);
Vue.use(NavBar);
Vue.use(Form);
Vue.use(Field);
Vue.use(Button);
Vue.use(ShareSheet);
Vue.use(Cell);
Vue.use(Popup);
Vue.use(PullRefresh);
Vue.use(Sticky);
Vue.use(Search);
Vue.use(infiniteScroll)
Vue.use(waterfall);
Vue.use(Dialog);
Vue.use(Tag);
Vue.use(CellGroup);
























//点击相同路由报错的解决方法, 捕获错误
let originPush = VueRouter.prototype.push;

//重新VueRouter的原型的push方法
VueRouter.prototype.push = function (location) {
  //location: 目标路由的信息
  // ('location ==> ', location);

  originPush.call(this, location, () => { }, (err) => {
    // ('err ==> ', err);
  });
}



Vue.config.productionTip = false


axios.interceptors.request.use(config => {
  //config: 请求配置(请求头, 请求参数, 请求类型, 请求路径, ....)
 

  


  if(config.data===""){
    Toast('加载失败')
  }
  

  //处理请求的公共参数
  if (config.method === 'get') {
    config.params = config.params || {};

  }

    //启动加载提示
    Toast.loading({
      message: '加载中...',
      //禁止穿透点击
      forbidClick: true,
      loadingType: 'spinner',
      //不会自动关闭提示
      duration: 0
    })






  return config;
}, err => {
  

  //关闭加载提示
  Toast.clear();
  return Promise.reject(err);
})


//添加一个响应之前拦截器
axios.interceptors.response.use(res => {
  //res: 服务器响应数据
  
  
   //关闭加载提示
   Toast.clear();
  
   return res;
  }, err => {
   
  
   //关闭加载提示
   Toast.clear();
  
   return Project.reject(err);
  })




new Vue({
  router,
  store,

  render: h => h(App)
}).$mount('#app')
